'''
Created on May 24, 2011

@author: Roni
'''
import cliques.utils

class Scenario(object):
    ''' An experiment instance '''
    
    def __init__(self,a_graph,a_start_node):
        self.unknown_graph = a_graph
        self.start_node = a_start_node

    def store(self,file_name):        
        cliques.utils.export_graph(self.unknown_graph,"%s.graph" % file_name)
        start_node_file = open("%s.start" % file_name,"w")
        start_node_file.write("%s\n" % self.start_node)
        start_node_file.close()
    
    @staticmethod
    def load(file_name):
        a_graph = cliques.utils.import_graph("%s.graph" % file_name)
        a_graph = cliques.utils.convert_node_names_to_numbers(a_graph)
        start_node_file = open("%s.start" % file_name,"r")
        a_start_node = start_node_file.read().strip()
        a_start_node = int(a_start_node)
        start_node_file.close()
        
        return Scenario(a_graph,a_start_node)